using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace StupidSpaceThing
{
	public enum GuideState { Normal, FadeOut, FadeIn };
	public delegate void GuideCallback();

	internal abstract class Guide
	{
		public readonly double Duration;
		public double StartTime { get { return startTime; } }
		private double startTime = 0;
		protected GuideState state = GuideState.FadeIn;
		public GuideState State { get { return state; } }
		private int alpha = 0;
		public int Alpha {
			get { return alpha; }
			set {
				alpha = value;
				if( alpha < 0 ) alpha = 0;
				if( alpha > 255 ) alpha = 255;
			}
		}
		public Color Color { get { return new Color(255, 255, 255, (byte)Alpha); } }
		public Color GetColor(Color color) {
			return new Color(color.R, color.G, color.B, (byte)Alpha);
		}
		public GuideCallback Callback;
		
		public Guide(double duration) {
			this.Duration = duration;
		}

		public Guide(double duration, GuideCallback callback) {
			this.Duration = duration;
			this.Callback = callback;
		}

		public void Start(double startTime) {
			this.startTime = startTime;
		}

		public virtual void End() {
			state = GuideState.FadeOut;
		}

		public virtual void Update(RealGameTime gameTime) {

		}

		public virtual void Draw(SpriteBatch spriteBatch) {
			if( state == GuideState.FadeIn ) {
				Alpha += 10;
				if( Alpha == 255 ) {
					state = GuideState.Normal;
				}
			} else if( state == GuideState.FadeOut ) {
				Alpha -= 10;
			}
		}
	}
}
